package com.wzx;

import com.alibaba.druid.pool.DruidDataSource;
import com.mysql.cj.jdbc.Driver;
import com.wzx.core.ioc.anootaction.Bean;
import com.wzx.core.ioc.anootaction.ComponentScan;
import com.wzx.core.ioc.anootaction.Configuration;
import com.wzx.core.ioc.context.AnnotationApplicationContext;
import com.wzx.service.ITransferService;
import com.wzx.service.TransferService;
import com.wzx.service.User;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

@Configuration
@ComponentScan("com.wzx")
public class ApplicationStartup {

    public static void main(String[] args) throws Exception {
        Class.forName("com.mysql.cj.jdbc.Driver");
        AnnotationApplicationContext context = new AnnotationApplicationContext(ApplicationStartup.class);
        TransferService transferService = context.getBean("transferService");
        transferService.transfer(1, 2, 100);

//        User u = context.getBean("user");
//        System.out.println(u);
    }

    @Bean
    public Connection connection() throws SQLException {
        return DriverManager.getConnection("jdbc:mysql://127.0.0.1/wzxioc", "root", "root");
    }

}
